home *** CD-ROM | disk | FTP | other *** search
- /* BEGIN SOX COPYRIGHT ************************************************ */
- /*
- * July 5, 1991
- * Copyright 1991 Lance Norskog And Sundry Contributors
- * This source code is freely redistributable and may be used for
- * any purpose. This copyright notice must be maintained.
- * Lance Norskog And Sundry Contributors are not responsible for
- * the consequences of using this software.
- */
- /* END SOX COPYRIGHT ************************************************ */
-
- /* copied from sox */
- /* modified by David Lai, Jan 6 1993, daver!fastfood!lai */
-
- /* BEGIN DAVID LAI COPYRIGHT ********************************************* */
- /*
- (C) Copyright David Lai 1993, 1994. All rights reserved.
-
- The source code is copyright by David Lai, however it is freely
- distributable and released for unrestricted use. Users may copy or modify
- this source code without charge, provided all copyright
- notices remain intact in all the source code. Portions of the source code
- copyright by their respective copyright holders and are covered
- under different agreements, however the source code used has
- specifically been marked distributable royalty-free.
-
- You can do whatever you want with it, even charge money for it, if
- you find a sucker willing to pay for it. This is not shareware, the program
- is not crippled in any way, do not send money. You can e-mail comments
- to the electronic mail address below, or fax to the fax number below.
-
- If you add a feature thats useful, or do a new port, you can send
- the context diffs to the e-mail address below. I may include it in
- subsequent releases. Your code must specifically be marked
- freely distributable, I will not include code marked otherwise.
-
- THE SOURCE CODE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING
- THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
-
- The source code is provided with no support and without any obligation on
- the part of David Lai to assist in its use, correction,
- modification or enhancement.
-
- DAVID LAI SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS SOFTWARE
- OR ANY PART THEREOF.
-
- In no event will David Lai be liable for any lost revenue
- or profits or other special, indirect and consequential damages, even if
- David Lai has been advised of the possibility of such damages.
-
- David Lai
- 1370 McKendrie St
- San Jose, CA 95126
- fax: 408-241-4615
-
- lai%fastfood@daver.bungi.com
-
- */
- /* END DAVID LAI COPYRIGHT ********************************************* */
-
- /* sometimes microsoft C only defines _DOS */
- #ifdef _DOS
- #ifndef __MSDOS__
- #define __MSDOS__
- #endif
- #endif
-
- #ifdef VAXC
- #define IMPORT globalref
- #define EXPORT globaldef
- /*
- * use the VAX C optimized functions
- */
- #define calloc VAXC$CALLOC_OPT
- #define cfree VAXC$CFREE_OPT
- #define free VAXC$FREE_OPT
- #define malloc VAXC$MALLOC_OPT
- #define realloc VAXC$REALLOC_OPT
- #else
- #define IMPORT extern
- #define EXPORT
- #endif
-
- #ifdef __STDC__
- #define PROTO(x) x
- #else
- /* Some non-ansi compilers (eg. sun SunOs version 4) */
- #define signed
- #define const
- #define volatile
- #define PROTO(x) ()
- #define NO_CONSTANT_SUFFIX
- #endif
-
- #ifdef sun
- /* SunOs version 4 doesnt define SEEK_SET */
- #define SEEK_SET 0
- #endif
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <assert.h>
-
- #ifdef AMIGA
- #include "amiga.h"
- #endif /* AMIGA */
-
- #ifdef __STDC__
- #define P1(x) x
- #define P2(x,y) x, y
- #define P3(x,y,z) x, y, z
- #define P4(x,y,z,w) x, y, z, w
- #else
- #define P1(x)
- #define P2(x,y)
- #define P3(x,y,z)
- #define P4(x,y,z,w)
- #endif
-
- #ifdef __MSDOS__
- /* the only compiler I know of where int is 16 bits */
- #define int16 int
- #define int32 long
- #define uint16 unsigned int
- #define uint32 unsigned long
- #define FMT_I32 "%ld"
- #define FMT_U32 "%lu"
- #else
- #define int16 short
- #define int32 int
- #define uint16 unsigned short
- #define uint32 unsigned int
- #define FMT_I32 "%d"
- #define FMT_U32 "%u"
- #endif
-
- #if defined(__MSDOS__) || defined(VAXC)
- #define LE /* little endian */
- #else
- #define BE /* big endian */
- #endif
-
- /* Utilities to read and write shorts and longs little-endian and big-endian */
- uint16 rlshort(P1(FILE * ft)); /* short little-end */
- uint16 rbshort(P1(FILE * ft)); /* short big-end */
- void wlshort(P2(FILE * ft, uint16 us)); /* short little-end */
- void wbshort(P2(FILE * ft, uint16 us)); /* short big-end */
- uint32 rllong(P1(FILE * ft)); /* long little-end */
- uint32 rblong(P1(FILE * ft)); /* long big-end */
- void wllong(P2(FILE * ft, uint32 ul)); /* long little-end */
- void wblong(P2(FILE * ft, uint32 ul)); /* long big-end */
- void wezstr( P2(FILE * ft, char *str));
- /* write null term string + pad to even number of bytes */
-
- #if defined(unix) || defined(AMIGA) || defined (__OS2__) || defined(OS9)
- #define READBINARY "r"
- #define WRITEBINARY "w"
- #endif
- #ifdef VMS
- #define READBINARY "r", "mbf=16", "ctx=stm"
- #define WRITEBINARY "w", "ctx=stm"
- #endif
- #ifdef __MSDOS__
- #define READBINARY "rb"
- #define WRITEBINARY "wb"
- #endif
-
- /* Error code reporting */
- #ifdef QNX
- #include <errno.h>
- #endif
-
- #if defined(unix) || defined(__OS2__)
- #include <errno.h>
- extern errno;
- #if defined(i386) || !defined(__STDC__)
- /* usually be a const in stdlib.h ?? */
- /* this is turning out to be a headache */
- extern char *sys_errlist[];
- #define strerror(errno) sys_errlist[errno]
- #endif
- #endif
-
- #ifdef __OS2__
- #define REMOVE remove
- #else
- #define REMOVE unlink
- #endif
-
- #define err_exit(str,arg) (fprintf(stderr, str, arg),fprintf(stderr,"\n"),exit(1))
- /* signed <> unsigned char conversions */
- #define s_to_u(c) ((c) ^ 128)
- #define u_to_s(uc) ((uc) ^ 128)
-
- #ifndef __MSDOS__
- #define FWRITE fwrite
- #define FREAD fread
- #else
- extern uint32 FWRITE PROTO((const void * buffer, size_t size, uint32 count, FILE *stream));
- extern uint32 FREAD PROTO((const void * buffer, size_t size, uint32 count, FILE *stream));
- #endif
-
- #if 0
- $Id: misc.h,v 1.1 1994/03/19 09:21:31 dlai Exp $
- $Log: misc.h,v $
- * Revision 1.1 1994/03/19 09:21:31 dlai
- * Initial revision
- *
-
- #endif
-